export interface BaseRes<T = null> {
  code: number
  msg: string
  data: T
}

// 登录验证码
export type CaptchaRes = {
  code: string
}

// 登录参数
export type LoginParams = Record<'username' | 'password' | 'code', string>
// 登录返回值
export type LoginRes = {
  token: string
}

// 当前用户可访问的菜单
export type MenuItem = {
  createTime: number
  disabled: boolean
  isBtn: boolean
  name: string
  path: string,
  pid: string,
  _id: string,
  children?: MenuItem[]
}

export type UserMenuListRes = {
  list: MenuItem[]
}

// 权限类型
export type PermissionItem = Omit<MenuItem, 'children'>

// 当前用户信息
export type UserInfo = {
  _id: string
  username: string
  role: string[]
  permission: PermissionItem[]
  avator?: string
  age?: number
  email?: string
  sex?: string
}

// 用户管理列表
export type UserListParams = {
  page: number
  pagesize: number
  creator?: string
  status?: 0 | 1
  username?: string
}
export type UserItem = {
  creator: string
  lastOnlineTime: number
  password: string
  role: string[]
  status: 0 | 1
  username: string
  _id: string
  avator?: string
}
export type UserListRes = {
  total: number
  list: UserItem[]
}
// 创建用户
export type CreateUserParams = Pick<UserItem, 'username' | 'password' | 'status'>
// 更新用户参数
export type UpdateUserParams = { id: string } & Partial<Omit<UserItem, '_id' | 'lastOnlineTime' | 'creator'>>
// 角色列表
export type RoleItem = {
  _id: string
  name: string
  value: string
  permission: string[]
  disabled: boolean
  creator: string
  createTime: number
}
export type RoleListRes = {
  total: number
  list: RoleItem[]
}
// 权限菜单
export type PermissionRes = {
  list: MenuItem[]
}